package com.example.shutdown_v1.entity;

import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;

/**
 * 传感器基准值历史记录实体
 * 记录每次自动校准时的基准值变更历史
 */
@Entity
@Table(name = "sensor_baseline_history", indexes = {
        @Index(name = "idx_sensor_id", columnList = "sensor_id"),
        @Index(name = "idx_created_at", columnList = "created_at"),
        @Index(name = "idx_sensor_model", columnList = "sensor_model")
})
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class SensorBaselineHistory {
    
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    
    /**
     * 传感器MAC地址
     */
    @Column(name = "sensor_id", nullable = false, length = 20)
    private String sensorId;
    
    /**
     * 传感器型号
     */
    @Column(name = "sensor_model", nullable = false, length = 20)
    private String sensorModel;
    
    /**
     * 加速度X轴基准值 (m/s²)
     */
    @Column(name = "accel_baseline_x")
    private Double accelBaselineX;
    
    /**
     * 加速度Y轴基准值 (m/s²)
     */
    @Column(name = "accel_baseline_y")
    private Double accelBaselineY;
    
    /**
     * 加速度Z轴基准值 (m/s²)
     */
    @Column(name = "accel_baseline_z")
    private Double accelBaselineZ;
    
    /**
     * Roll基准值 (度)
     */
    @Column(name = "roll_baseline_closed")
    private Double rollBaselineClosed;
    
    /**
     * Pitch基准值 (度)
     */
    @Column(name = "pitch_baseline_closed")
    private Double pitchBaselineClosed;
    
    /**
     * Yaw基准值 (度)
     */
    @Column(name = "yaw_baseline_closed")
    private Double yawBaselineClosed;
    
    /**
     * 记录创建时间
     */
    @Column(name = "created_at", nullable = false)
    private LocalDateTime createdAt;
    
    /**
     * 校准类型: auto-自动校准, manual-手动校准, init-初始化
     */
    @Column(name = "calibration_type", nullable = false, length = 20)
    private String calibrationType;
    
    /**
     * 上次基准值的年龄(天数)
     */
    @Column(name = "baseline_age_days")
    private Integer baselineAgeDays;
}

